#include "invokeobject.h"
#include <QDebug>

InvokeObject::InvokeObject(QObject *parent) : QObject(parent)
{

}

void InvokeObject::init(QObject *rootObj)
{
    m_rootObj = rootObj;
}

void InvokeObject::loadText(QString text)
{
    cacheText = text;
    QObject* textObj = m_rootObj->findChild<QObject*>("PagePluginExampleLabel");
    if(textObj)
    {
        qDebug()<<"loadText textObj"<<textObj<<text;
        textObj->setProperty("text",text);
    }
    qDebug()<<"loadText finish";
}

QString InvokeObject::getCacheText()
{
    return "Cache Text:"+cacheText;
}

void InvokeObject::openDialog()
{
    QObject* dialogObj = m_rootObj->findChild<QObject*>("PagePluginExampleMessageDialog");
    if(dialogObj)
    {
        qDebug()<<"openDialog dialogObj"<<dialogObj;
        QMetaObject::invokeMethod(dialogObj, "open");
    }
    qDebug()<<"openDialog finish";
}
